//
//  MainTabbarController.m
//  ZzzzyManProject
//
//  Created by mac on 16/2/24.
//  Copyright © 2016年 ZzzzyMan@. All rights reserved.
//

#import "MainTabbarController.h"
#import "HomeViewController.h"
#import "InformationViewController.h"
#import "MainNavController.h"


@interface MainTabbarController ()

@end

@implementation MainTabbarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置选中颜色
    self.tabBar.tintColor = [UIColor blackColor];
    //添加所有子控制器
    [self addAllViewController];

}

#pragma mark - 添加所有子控制器
- (void)addAllViewController {
    [self addChildViewController:[[HomeViewController alloc] init] andTitle:@"首页" andImageName:@"tabbar3"];
    [self addChildViewController:[[InformationViewController alloc] init] andTitle:@"资讯" andImageName:@"tabbar2"];
}


#pragma mark - 添加子控制器
- (void)addChildViewController:(UIViewController *)childController andTitle:(NSString *)title andImageName:(NSString *)imageName {
    
    //设置子控制器的tabbar图片
    [childController.tabBarItem setImage:[UIImage imageNamed:imageName]];
    
    childController.title = title;
    
    self.tabBar.tintColor = [UIColor blackColor];
    
    UINavigationController * navVC = [[MainNavController alloc] initWithRootViewController:childController];
    
    [self addChildViewController:navVC];
}

@end
